package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.CustomerDeliverAddress;
import com.pgybook.db.entity.domain.CustomerDeliverAddressEx;
import org.apache.ibatis.annotations.*;


import java.util.List;


@Repository
public interface CustomerDeliverAddressMapper {
    int countByExample(CustomerDeliverAddressEx example);

    int deleteByExample(CustomerDeliverAddressEx example);

    @Delete({
            "delete from customerdeliveraddress",
            "where CUSTADDRESSID = #{custaddressid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer custaddressid);

    @Insert({
            "insert into customerdeliveraddress (CUSTID, ADDRESS, ",
            "CONTACT, PHONE, ",
            "ZIPCODE, CRTTIME, ",
            "ISDEFAULT)",
            "values (#{custid,jdbcType=BIGINT}, #{address,jdbcType=VARCHAR}, ",
            "#{contact,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, ",
            "#{zipcode,jdbcType=VARCHAR}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{isdefault,jdbcType=BIT})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "custaddressid", before = false, resultType = Integer.class)
    int insert(CustomerDeliverAddress record);

    int insertSelective(CustomerDeliverAddress record);

    List<CustomerDeliverAddress> selectByExample(CustomerDeliverAddressEx example);

    @Select({
            "select",
            "CUSTADDRESSID, CUSTID, ADDRESS, CONTACT, PHONE, ZIPCODE, CRTTIME, ISDEFAULT",
            "from customerdeliveraddress",
            "where CUSTADDRESSID = #{custaddressid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CustomerDeliverAddress selectByPrimaryKey(Integer custaddressid);

    int updateByExampleSelective(@Param("record") CustomerDeliverAddress record, @Param("example") CustomerDeliverAddressEx example);

    int updateByExample(@Param("record") CustomerDeliverAddress record, @Param("example") CustomerDeliverAddressEx example);

    int updateByPrimaryKeySelective(CustomerDeliverAddress record);

    @Update({
            "update customerdeliveraddress",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "ADDRESS = #{address,jdbcType=VARCHAR},",
            "CONTACT = #{contact,jdbcType=VARCHAR},",
            "PHONE = #{phone,jdbcType=VARCHAR},",
            "ZIPCODE = #{zipcode,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "ISDEFAULT = #{isdefault,jdbcType=BIT}",
            "where CUSTADDRESSID = #{custaddressid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CustomerDeliverAddress record);
}
